package com.ms.service.module.analysis.db.model;

import javax.persistence.Entity;
import javax.persistence.Table;

import com.ms.service.module.analysis.PlayerEnterSeatStatusType;
import com.xpec.c4.db.model.log.basic.BasicLogModel;

@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Table(name="player_enter_seat_log")
@org.hibernate.annotations.Table(
		appliesTo = "player_enter_seat_log", indexes =
		{
				@org.hibernate.annotations.Index(name = "IDX_PLAYER_ID", columnNames = { "playerId","eventTime"}),
		}
)
public class PlayerEnterSeatLogModel extends BasicLogModel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5333698735472186617L;

	/**
	 * 玩家名稱(暱稱)，包含nameNumber
	 */
	private String playerName;
	
	/**
	 * 玩家ID
	 */
	private String playerId;
	
	/**
	 * 遊戲類型
	 */
	private String gameType;
	
	/**
	 * 遊戲館類型
	 */
	private String hallType;
	
	/**
	 * 機台編號
	 */
	private String machineId;
	
	/**
	 * 紀錄狀態
	 */
	private int status;
	
	/**
	 * 紀錄狀態描述
	 */
	private String statusDesc;
	
	
	public String getPlayerName() {
		return playerName;
	}

	public void setPlayerName(String playerName) {
		this.playerName = playerName;
	}

	public String getPlayerId() {
		return playerId;
	}

	public void setPlayerId(String playerId) {
		this.playerId = playerId;
	}

	public String getGameType() {
		return gameType;
	}

	public void setGameType(String gameType) {
		this.gameType = gameType;
	}

	public String getHallType() {
		return hallType;
	}

	public void setHallType(String hallType) {
		this.hallType = hallType;
	}

	public String getMachinId() {
		return machineId;
	}

	public void setMachinId(String machinId) {
		this.machineId = machinId;
	}

	public int getStatus() {
		return status;
	}

	/**
	 * 出入座狀態
	 * @param status {@link PlayerEnterSeatStatusType}
	 */
	public void setStatus(int status) {
		this.status = status;
		//Set狀態時順便Set描述
		this.setStatusDesc(status);
	}

	public String getStatusDesc() {
		return statusDesc;
	}
	
	//用private以免不小心在外面亂改到
	private void setStatusDesc(int enterseatstatus) {
		if(enterseatstatus == PlayerEnterSeatStatusType.ENTER_SEAT_REQUEST.getStatus()){
			this.statusDesc = PlayerEnterSeatStatusType.ENTER_SEAT_REQUEST.getStatusDesc();
		}
		else if(enterseatstatus == PlayerEnterSeatStatusType.ENTER_SEAT_SUCCESS.getStatus()){
			this.statusDesc = PlayerEnterSeatStatusType.ENTER_SEAT_SUCCESS.getStatusDesc();
		}
		else if(enterseatstatus == PlayerEnterSeatStatusType.LEAVE_SEAT.getStatus()){
			this.statusDesc = PlayerEnterSeatStatusType.LEAVE_SEAT.getStatusDesc();
		}
		else if(enterseatstatus == PlayerEnterSeatStatusType.OFFLINE_KEEP_SEAT.getStatus()){
			this.statusDesc = PlayerEnterSeatStatusType.OFFLINE_KEEP_SEAT.getStatusDesc();
		}
		else if(enterseatstatus == PlayerEnterSeatStatusType.OFFLINE_SPIN.getStatus()){
			this.statusDesc = PlayerEnterSeatStatusType.OFFLINE_SPIN.getStatusDesc();
		}
		else if(enterseatstatus == PlayerEnterSeatStatusType.LEAVE_OFFLINE_SPIN.getStatus()){
			this.statusDesc = PlayerEnterSeatStatusType.LEAVE_OFFLINE_SPIN.getStatusDesc();
		}		
		else {
			this.statusDesc = PlayerEnterSeatStatusType.UNKNOW_DESCRIPTION.getStatusDesc();			
		}		
	}
}
